﻿<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'address-form',
	'enableAjaxValidation'=>false,
)); ?>

	<p class="note">Fields with <span class="required">*</span> are required.</p>

	<?php echo $form->errorSummary($model); ?>

	<div class="row">
		<?php echo $form->labelEx($model,'name'); ?>
		<?php echo $form->textField($model,'name',array('size'=>45,'maxlength'=>45)); ?>
		<?php echo $form->error($model,'name'); ?>
	</div>
	
	<div class="row">
		<?php echo $form->labelEx($model,'telephone'); ?>
		<?php echo $form->textField($model,'telephone',array('size'=>11,'maxlength'=>11)); ?>
		<?php echo $form->error($model,'telephone'); ?>
	</div>	
	
	<div class="row">
		<?php echo $form->labelEx($model,'country'); ?>
		<?php
		echo CHtml::activeDropDownList($model,'country',array(1=>'中国'));		
		?>
	</div>
	
	<div class="row">
		<?php echo $form->labelEx($model,'province'); ?>
		<?php echo CHtml::activeDropDownList($model,'province',Region::model()->getProvinceOpinions(),
		array(
		'ajax' => array(
		'type'=>'POST', //request type
		'url'=>Yii::app()->createUrl('address/dynamicCities'),
		'update'=>'#Address_city', //selector to update
		'data'=> array('province'=>'js:this.value'),
	))); 
		?>
		
	<div class="row">
		<?php echo $form->labelEx($model,'city'); ?>
		<?php
		echo CHtml::activeDropDownList($model,'city',Region::model()->getCityOpinions(2),
		array(
		'ajax' => array(
		'type'=>'POST', //request type
		'url'=>Yii::app()->createUrl('address/dynamicAreas'),
		'update'=>'#Address_district', //selector to update
		'data'=>array('city'=>'js:this.value'), 
	))); 
		?>
		
	<div class="row">
		<?php echo $form->labelEx($model,'district'); ?>
		<?php
		echo CHtml::activeDropDownList($model,'district',Region::model()->getAreaOpinions(52));		
		?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'address'); ?>
		<?php echo $form->textField($model,'address',array('size'=>60,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'address'); ?>
	</div>


	<div class="row">
		<?php echo $form->labelEx($model,'zipcode'); ?>
		<?php echo $form->textField($model,'zipcode',array('size'=>6,'maxlength'=>6)); ?>
		<?php echo $form->error($model,'zipcode'); ?>
	</div>

	<div class="row buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
	</div>

<?php $this->endWidget(); ?>

</div><!-- form -->